﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TestGenerator.Input;

namespace TestGenerator.Generator
{
    class GeneratedQuestion
    {
        private string name;
        private int correctAnswerIndex;     
        private List<string> answers;

        public List<string> Answers
        {
            get { return answers; }
            set { answers = value; }
        }
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        public int CorrectAnswerIndex
        {
            get { return correctAnswerIndex; }
            set { correctAnswerIndex = value; }
        }

        public GeneratedQuestion(string name,int correctIndex, List<string> answersList)
        {
            if (name == "")
            {
                throw new ArgumentException("The Question must have non-empty name!");
            }
            this.Name = name;

            this.correctAnswerIndex = correctIndex;

            if (answersList.Count < 2)
            {
                throw new ArgumentException("The Question must have at least 2 possible answers ! ");
            }

            this.Answers = new List<string>(answersList);      
        }

        public override string ToString()
        {
            string result = name + "\n"; ;
            int answerindex = 0;
            foreach (var item in answers)
            {
                result += ++answerindex + ") " + item + "\n";
            }

            return result;
        }


    }
}
